﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DBBase;
using System.Security;
using System.Security.Cryptography;

using System.Text.RegularExpressions;


namespace Business
{
    public partial class jiekoushezhi : Form
    {
        public jiekoushezhi(string szzjg)
        {
            InitializeComponent();
            textBox1.Text = szzjg;
        }

        private void but_save_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("组织机构不允许为空");
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("不允许为空");
                return;
            }
            if (textBox3.Text == "")
            {
                MessageBox.Show("不允许为空");
                return;
            }
            if (textBox4.Text == "")
            {
                MessageBox.Show("不允许为空");
                return;
            }
            if (textBox5.Text == "")
            {
                MessageBox.Show("不允许为空");
                return;
            }
            if (textBox6.Text == "")
            {
                MessageBox.Show("不允许为空");
                return;
            }
            Query objquery = new Query();
            string ssql = "";
            ssql = string.Format(@"Select count(*) From ShouQuan where SQ_ZJJG='{0}'", textBox1.Text);
            if (objquery.ExecuteS(ssql))
            {
                MessageBox.Show("组织机构信息不允许编辑");
            }
            else
            {
                ssql = string.Format(@"insert into ShouQuan (
                                        SQ_ZJJG,
                                        SQ_JKMS,
                                        SQ_JKSQM,
                                        SQ_FWDZ,
                                        SQ_SQRQ,
                                        SQ_SQR) values 
                                        ('{0}',
                                        '{1}',
                                        '{2}',
                                        '{3}',
                                        '{4}',
                                        '{5}')", textBox1.Text,
                                                textBox2.Text,
                                                textBox3.Text,
                                                textBox4.Text,
                                                textBox5.Text,
                                                textBox6.Text);
                if (!objquery.UpdateTable(ssql))
                {
                    MessageBox.Show("添加失败");
                }
                else
                {
                    MessageBox.Show("新增成功");
                }
                this.Close();
            }
        }

       
       
      
    }
}
